package org.easy4j.framework.common.service;

import org.easy4j.framework.core.orm.BaseDao;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author bjliuyong
 * @version 1.0
 * @created date 16-1-7
 */
@Deprecated
public abstract class BaseService<M>  {

    @Autowired(required = false)
    protected BaseDao<M> baseDao ;

    public void setBaseDao(BaseDao<M> baseDao) {
        this.baseDao = baseDao ;
    }

    public long save(M m ){
        return baseDao.save(m ,Long.class);
    }

    public M findById(long id) {
        return baseDao.queryObject("where id=?" , id) ;
    }

    public boolean updateById(M m ) {
        return baseDao.update(m) == 1;
    }

    public BaseDao<M> getBaseDao(){
        return baseDao ;
    }

}
